<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
</head>
<body>
<!--<div class="layuimini-container">-->
<div class="layuimini-main">
    <div class="layui-row layui-col-space15">
        <fieldset class="table-search-fieldset">
            <div class="layui-col-xs12 layui-col-md6">
                <div id="echarts-dataset" style="background-color:#ffffff;min-height:600px;padding: 10px"></div>
            </div>
            <div class="layui-col-xs12 layui-col-md6">
                <div id="echarts-pies" style="background-color:#ffffff;min-height:500px;padding: 10px"></div>
            </div>
        </fieldset>
    </div>


</div>
<!--</div>-->
{include file="public/footer" /}
<script>
    layui.use(['layer', 'echarts'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            echarts = layui.echarts;
        /**
         * 柱状图
         */
        var echartsDataset = echarts.init(document.getElementById('echarts-dataset'), 'walden');

        var optionDataset = {
            title: {
                text: '当前生意总数：{$businessStatusTotal}',
                subtext: '生意状态分析',
                textStyle: {
                    color: 'red',
                },
                padding: [0, 0, 10, 100]  // 位置
            },
            legend: {
                type: 'plain',  // 图列类型，默认为 'plain'
                top: '1%',  // 图列相对容器的位置 top\bottom\left\right
            },
            tooltip: {
                trigger: 'item',
                formatter: function (params) {
                    if ("{$businessStatusTotal}" != 0) {
                        return params.name + "<br />" +
                            '数量：' + params.data + ' ' + "<br />" +
                            '占比：' + ((parseInt(params.data) / parseInt("{$businessStatusTotal}")) * 100).toFixed(2) + '%';
                    }
                }
            },
            xAxis: {
                type: 'category',
                axisLabel: {
                    formatter : function(params,val){
                        let x = [{$businessStatus}][val]
                        if(x==undefined || x=='undefined'){
                            x=0;
                        }
                        return params.replace('&middot;','.')+"\n\n数量:"+x+"\n占比:"+((parseInt(x) / parseInt("{$businessStatusTotal}")) * 100).toFixed(2) + '%';
                    }
                },
                data: ['收益中', '待出售', '出售中', '待交租', '已冻结']
            },
            yAxis: {
                type: 'value',
            },
            series: [
                {
                    type: 'bar',
                    data: [{$businessStatus}],
                },
            ]
        };
        echartsDataset.setOption(optionDataset);
        echartsDataset.on('click', function (params) {


        });
        /**
         * 等级分布
         */
        var gradeDistribution = JSON.parse(decodeURIComponent('{$gradeDistribution}'));
        var echartsPies = echarts.init(document.getElementById('echarts-pies'), 'walden');
        var optionPies = {
            title: {
                text: '等级分布',
                left: 'center'
            },
            tooltip: {
                trigger: 'item',
                formatter: '{a} <br/>{b} : {c} ({d}%)'
            },
            legend: {
                type: 'scroll',
                orient: 'vertical',
                right: 10,
                top: 20,
                bottom: 20,
                data: [{$gradeDistributionTitle}],
            },
            series: [
                {
                    name: '等级分布',
                    type: 'pie',
                    radius: '55%',
                    center: ['50%', '60%'],
                    data: gradeDistribution,
                    emphasis: {
                        itemStyle: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };
        echartsPies.setOption(optionPies);

        // echarts 窗口缩放自适应
        window.onresize = function () {
            echartsDataset.resize();
            echartsPies.resize();
        }

    });
</script>
</body>
</html>
